<extend name="Layout/ins_popup" />
<block name="content">
	<input type="hidden" name="val" id="val">
	<input type="hidden" name="name" id="name">
	<input type="hidden" name="ajax" id="ajax" value="1">
	<div class="popup-frame">
		<input type="hidden" name="ajax" id="ajax" value="1">
		<div class="popup-header">
			<div class="pull-left">
				<h1>请选择父节点</h1>
			</div>
			<div class="pull-right">
				<a id="save" class="btn" >确定</a>
				<a id="close" class="btn btn-cancel">关闭</a>
			</div>
		</div>
		<div class="popup-body">
			<div class="popup-body-scroll">
				<div class="popup-content">
					<div class="popup_tree_menu">
						<ul class="tree_menu">
							<li>
								<a node="0"><i class="icon"></i> <span>根节点</span> </a>
								{$menu}
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name);
		layui.use(['global'], function() {
			var $ = layui.jquery;
			
			
			var layer = layui.layer;

			//保存后关闭
			$('#save').on('click', function() {
				if ($("#name").val().length == 0) {
					layer.msg("请选择节点");
					return false;
				}
				$("#folder_name", parent.document).val($("#name").val());
				$("#pid", parent.document).val($("#val").val());
				parent.layer.close(index);
			});

			parent_node = $(".sub-sidebar ul.tree_menu a.active", parent.document).attr("node");
			$("ul.tree_menu a[node='" + parent_node + "']").parent().hide();
			$(".popup_tree_menu a:not('.disabled')").click(function() {
				$this = $(this);
				$("#val").val($this.attr("node"));
				$("#name").val($this.children("span").text());
				$(".tree_menu a.active").removeClass("active");
				$this.addClass("active");
			});

			//关闭iframe
			$('#close').click(function() {
				parent.layer.close(index);
			});
		});
		function save() {

		}

	</script>
</block>